﻿//===================================================================
// 西交通开发框架-XCI.Parent 2019 版权所有     
//===================================================================
using System.ComponentModel.DataAnnotations;
using XCI.Core;

namespace XCI.Sys.Model
{
    /// <summary>
    /// 系统模块
    /// </summary>
    [ApiModel(Caption = "系统模块")]
    public class SysModule
    {
        /// <summary>
        /// 模块主键
        /// </summary>
        [Display(Name = "模块主键")]
        [ApiModelProperty(PrimaryKey = true)]
        public string Id { get; set; }

        /// <summary>
        /// 模块上级主键
        /// </summary>
        [Display(Name = "模块上级主键")]
        [ApiModelProperty(ParentKey = true)]
        public string ParentId { get; set; }

        /// <summary>
        /// 模块
        /// </summary>
        [Display(Name = "模块")]
        public string NameCode => $"{Name}({Code})";

        /// <summary>
        /// 模块名称
        /// </summary>
        [Display(Name = "模块名称")]
        [Required(ErrorMessage = "请输入模块名称")]
        [StringLength(100, ErrorMessage = "模块名称不能超过100个字符")]
        public string Name { get; set; }

        /// <summary>
        /// 模块编码
        /// </summary>
        [Display(Name = "模块编码")]
        [Required(ErrorMessage = "请输入模块编码")]
        [StringLength(100, ErrorMessage = "模块编码不能超过100个字符")]
        public string Code { get; set; }

        /// <summary>
        /// 模块简拼
        /// </summary>
        [Display(Name = "模块简拼")]
        [StringLength(100, ErrorMessage = "模块简拼不能超过100个字符")]
        public string Spell { get; set; }

        /// <summary>
        /// 模块参数
        /// </summary>
        [Display(Name = "模块参数")]
        [StringLength(1000, ErrorMessage = "模块参数不能超过1000个字符")]
        public string Param { get; set; }

        /// <summary>
        /// Web图标
        /// </summary>
        [Display(Name = "Web图标")]
        [StringLength(100, ErrorMessage = "Web图标不能超过100个字符")]
        public string WebCls { get; set; }

        /// <summary>
        /// Web地址
        /// </summary>
        [Display(Name = "Web地址")]
        [StringLength(500, ErrorMessage = "Web地址不能超过500个字符")]
        public string WebUrl { get; set; }

        /// <summary>
        /// Win图标
        /// </summary>
        [Display(Name = "Win图标")]
        [StringLength(100, ErrorMessage = "Win图标不能超过100个字符")]
        public string WinCls { get; set; }

        /// <summary>
        /// Win路径
        /// </summary>
        [Display(Name = "Win路径")]
        [StringLength(500, ErrorMessage = "Win路径不能超过500个字符")]
        public string WinUrl { get; set; }

        /// <summary>
        /// Web应用
        /// </summary>
        [Display(Name = "Web应用")]
        public bool IsWeb { get; set; }

        /// <summary>
        /// WinForm应用
        /// </summary>
        [Display(Name = "WinForm应用")]
        public bool IsWin { get; set; }

        /// <summary>
        /// 是否展开
        /// </summary>
        [Display(Name = "是否展开")]
        public bool IsExpand { get; set; }

        /// <summary>
        /// 是否公开
        /// </summary>
        [Display(Name = "是否公开")]
        public bool IsPublic { get; set; }

        /// <summary>
        /// 是否菜单
        /// </summary>
        [Display(Name = "是否菜单")]
        public bool IsMenu { get; set; }

        /// <summary>
        /// 是否权限
        /// </summary>
        [Display(Name = "是否权限")]
        public bool IsPermission => !IsMenu;

        /// <summary>
        /// 排序路径
        /// </summary>
        [Display(Name = "序号")]
        [ApiModelProperty(PathKey = true)]
        public string Path { get; set; }

        /// <summary>
        /// 状态 [true-启用, false-禁用]
        /// </summary>
        [Display(Name = "状态")]
        public bool? Status { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Display(Name = "备注")]
        [StringLength(500, ErrorMessage = "备注不能超过500个字符")]
        public string Remark { get; set; }

        /// <summary>
        /// 复制对象
        /// </summary>
        public SysModule Clone()
        {
            return (SysModule)MemberwiseClone();
        }
    }
}
